package p270jp.pxv.android.notification.presentation.flux;

import androidx.lifecycle.AbstractC0720j0;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import p189gn.AbstractC3446l;
import p216hn.Lambda;
import p232id.ObservableHide;
import p270jp.pxv.android.commonObjects.model.Notification;
import p270jp.pxv.android.commonObjects.model.NotificationViewMore;
import p325m0.MutabilityOwnership;
import p425pk.NotificationsAction;
import p425pk.NotificationsEvent;
import p425pk.NotificationsState;
import p467rd.subscribers;
import p493sf.AbstractC6047g;
import p493sf.FluxUtils;
import p517td.BehaviorSubject;
import p593wc.AbstractC6902j;
import p603wm.Unit;
import p629xm.C7192p;
import p629xm.IteratorsJVM;
import p629xm._Collections;
import p671zc.CompositeDisposable;

/* compiled from: NotificationsStore.kt */
/* renamed from: jp.pxv.android.notification.presentation.flux.NotificationsStore */
/* loaded from: classes2.dex */
public final class NotificationsStore extends AbstractC0720j0 {

    /* renamed from: c */
    public final BehaviorSubject<NotificationsState> f19258c;

    /* renamed from: d */
    public final BehaviorSubject<NotificationsEvent> f19259d;

    /* renamed from: e */
    public final AbstractC6902j<NotificationsState> f19260e;

    /* renamed from: f */
    public final AbstractC6902j<NotificationsEvent> f19261f;

    /* renamed from: g */
    public List<Notification> f19262g = C7192p.f30161a;

    /* renamed from: h */
    public String f19263h;

    /* renamed from: i */
    public final CompositeDisposable f19264i;

    /* compiled from: NotificationsStore.kt */
    /* renamed from: jp.pxv.android.notification.presentation.flux.NotificationsStore$a */
    /* loaded from: classes2.dex */
    public static final class C4305a extends Lambda implements AbstractC3446l<FluxUtils, Unit> {
        public C4305a() {
            super(1);
        }

        @Override // p189gn.AbstractC3446l
        public Unit invoke(FluxUtils aVar) {
            NotificationsState rVar;
            FluxUtils aVar2 = aVar;
            MutabilityOwnership.m3745m(aVar2, "it");
            if (aVar2 instanceof NotificationsAction.C5627d) {
                NotificationsStore notificationsStore = NotificationsStore.this;
                notificationsStore.f19262g = C7192p.f30161a;
                notificationsStore.f19258c.mo305g(NotificationsState.C5643e.f24831a);
            } else if (aVar2 instanceof NotificationsAction.C5626c) {
                NotificationsStore notificationsStore2 = NotificationsStore.this;
                NotificationsAction.C5626c cVar = (NotificationsAction.C5626c) aVar2;
                notificationsStore2.f19262g = _Collections.m685c0(notificationsStore2.f19262g, cVar.f24810a.m3292b());
                NotificationsStore.this.f19263h = cVar.f24810a.m3293a();
                if (NotificationsStore.this.f19262g.isEmpty()) {
                    rVar = NotificationsState.C5639a.f24825a;
                } else {
                    NotificationsStore notificationsStore3 = NotificationsStore.this;
                    rVar = new NotificationsState.C5642d(notificationsStore3.f19262g, notificationsStore3.f19263h, cVar.f24811b);
                }
                NotificationsStore.this.f19258c.mo305g(rVar);
            } else if (aVar2 instanceof NotificationsAction.C5624a) {
                NotificationsStore.this.f19258c.mo305g(new NotificationsState.C5640b(((NotificationsAction.C5624a) aVar2).f24808a));
            } else if (aVar2 instanceof NotificationsAction.C5625b) {
                NotificationsStore.this.f19258c.mo305g(new NotificationsState.C5641c(((NotificationsAction.C5625b) aVar2).f24809a));
            } else if (aVar2 instanceof NotificationsAction.C5631h) {
                NotificationsStore.this.f19258c.mo305g(NotificationsState.C5644f.f24832a);
            } else if (aVar2 instanceof NotificationsAction.C5630g) {
                NotificationsStore.this.f19259d.mo305g(NotificationsEvent.C5636b.f24822a);
            } else if (aVar2 instanceof NotificationsAction.C5628e) {
                NotificationsStore.this.f19259d.mo305g(new NotificationsEvent.C5635a(((NotificationsAction.C5628e) aVar2).f24813a));
            } else if (aVar2 instanceof NotificationsAction.C5629f) {
                NotificationsStore.this.f19259d.mo305g(new NotificationsEvent.C5637c(((NotificationsAction.C5629f) aVar2).f24814a));
            } else if (aVar2 instanceof NotificationsAction.C5633j) {
                NotificationsStore notificationsStore4 = NotificationsStore.this;
                List<Notification> list = notificationsStore4.f19262g;
                ArrayList arrayList = new ArrayList(IteratorsJVM.m703K(list, 10));
                for (Notification notification : list) {
                    if (((NotificationsAction.C5633j) aVar2).f24818a.getId() == notification.getId()) {
                        NotificationViewMore viewMore = notification.getViewMore();
                        NotificationViewMore notificationViewMore = null;
                        if (viewMore != null) {
                            notificationViewMore = NotificationViewMore.copy$default(viewMore, null, false, 1, null);
                        }
                        notification = notification.copy((r18 & 1) != 0 ? notification.f18963id : 0, (r18 & 2) != 0 ? notification.createdDatetime : null, (r18 & 4) != 0 ? notification.type : 0, (r18 & 8) != 0 ? notification.content : null, (r18 & 16) != 0 ? notification.viewMore : notificationViewMore, (r18 & 32) != 0 ? notification.targetUrl : null, (r18 & 64) != 0 ? notification.isRead : false);
                    }
                    arrayList.add(notification);
                }
                notificationsStore4.f19262g = arrayList;
                NotificationsStore notificationsStore5 = NotificationsStore.this;
                notificationsStore5.f19258c.mo305g(new NotificationsState.C5642d(notificationsStore5.f19262g, notificationsStore5.f19263h, false));
            } else if (aVar2 instanceof NotificationsAction.C5632i) {
                NotificationsStore.this.f19259d.mo305g(NotificationsEvent.C5638d.f24824a);
            }
            return Unit.f29503a;
        }
    }

    public NotificationsStore(AbstractC6047g gVar) {
        MutabilityOwnership.m3745m(gVar, "readOnlyDispatcher");
        BehaviorSubject<NotificationsState> aVar = new BehaviorSubject<>();
        this.f19258c = aVar;
        BehaviorSubject<NotificationsEvent> aVar2 = new BehaviorSubject<>();
        this.f19259d = aVar2;
        Objects.requireNonNull(aVar);
        this.f19260e = new ObservableHide(aVar);
        Objects.requireNonNull(aVar2);
        this.f19261f = new ObservableHide(aVar2);
        CompositeDisposable aVar3 = new CompositeDisposable();
        this.f19264i = aVar3;
        aVar3.mo82c(subscribers.m2589g(gVar.mo2435a(), null, null, new C4305a(), 3));
    }

    @Override // androidx.lifecycle.AbstractC0720j0
    /* renamed from: b */
    public void mo315b() {
        this.f19264i.m80f();
    }
}
